package com.tjec.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.system.domain.BmsReportType;
import com.tjec.project.system.service.IBmsReportTypeService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 报告类别Controller
 * 
 * @author tjec
 * @date 2020-07-22
 */
@RestController
@RequestMapping("/system/reportType")
public class BmsReportTypeController extends BaseController
{
    @Autowired
    private IBmsReportTypeService bmsReportTypeService;

    /**
     * 查询报告类别列表
     */
    //@PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    public AjaxResult list(BmsReportType bmsReportType)
    {
        List<BmsReportType> list = bmsReportTypeService.selectBmsReportTypeList(bmsReportType);
        return AjaxResult.success(list);
    }

    /**
     * 报告类别新增/删除/修改
     */
    //@PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "报告类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<BmsReportType> bmsReportTypes)
    {
        return toAjax(bmsReportTypeService.insertBmsReportType(bmsReportTypes));
    }

    /**
     * 修改报告类别
     */
    //@PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "报告类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsReportType bmsReportType)
    {
        return toAjax(bmsReportTypeService.updateBmsReportType(bmsReportType));
    }


    /**
     * 根据业务类别id删除所有报告类别
     */
    //@PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "报告类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{businessTypeId}")
    public AjaxResult removeByBusinessTypeId(@PathVariable String businessTypeId)
    {
        return toAjax(bmsReportTypeService.deleteBmsReportTypeByBusinessTypeId(businessTypeId));
    }
}
